﻿/**
 * ...
 * @author George Mavchun
 */

package gui.hug;

import flash.display.Shape;
import flash.text.TextFieldAutoSize;
import gui.hug.priv.HUGBorder;

class HUGPopupWindow extends HUGSprite
{

	public function new(left : Int, top : Int, width : Int, height : Int, ?name : String)
	{
		super(left, top);
		if (name != null) {
			drawBorderComplex(width, height);
			drawName(name, width, height);
		} else {
			drawBorder(width, height);
		}
	}
	
	private function drawBorder(width : Int, height : Int) {
		var border : HUGBorder = new HUGBorder(width, height, HUGBorder.BASIC);	
		addChild(border);
	}
	
	private function drawBorderComplex(width : Int, height : Int) {
		var border : HUGBorder = new HUGBorder(width, height, HUGBorder.COMPLEX);	
		addChild(border);
	}
	
	private function drawName(text : String, width: Int, height: Int) {
		var left: Int = 11;
		var top: Int = 11;
		
		var label : HUGLabel = new HUGLabel();
		label.setLocation(left + 10, top + 4);
		label.setSize(width - 10, 26);
		label.autoSize = TextFieldAutoSize.LEFT;
		label.htmlText = "<b><font size='13' color='#FFFFFF' face='Tahoma'>" + text + "</font></b>";
		
		var shape = new Shape();
		shape.graphics.beginFill(HUGColors.VK_BUTTON);
		shape.graphics.drawRect(left, top, width - 22, 26);
		shape.graphics.endFill();
		
		var shapeDown = new Shape();
		shapeDown.graphics.beginFill(HUGColors.VK_BACKGROUND);
		shapeDown.graphics.drawRect(left, top + height - 62, width - 22, 40);
		shapeDown.graphics.endFill();
		
		var line: Shape = new Shape(); 
		line.graphics.lineStyle(1, HUGColors.VK_BORDER_OUTER);
		line.graphics.moveTo(left, top + height - 62);
		line.graphics.lineTo(left + width - 22, top + height - 62);
		
		
		addChild(shape);
		addChild(shapeDown);
		addChild(label);
		addChild(line);
	}
			
}